home *** CD-ROM | disk | FTP | other *** search
/ Young Minds / Young Minds Interactive CD-ROM.ISO / kriegspi / pawntrie.c < prev    next >
Encoding:
C/C++ Source or Header  |  1987-06-30  |  938 b   |  53 lines

  1. #ifndef lint
  2. static char rcsid[] = "$Header: pawntries.c,v 1.3 87/02/12 13:23:56 schoch Exp $";
  3. #endif
  4.  
  5. /* "pawntries.c */
  6. #include "externs.h"
  7.  
  8. countpawntries (color)
  9. u_char color;
  10. {
  11.     LIST l, moves, piecemoves ();
  12.     int tries, /* move,*/ start, end;
  13.  
  14.     tries = 0;
  15.     l = piecelocs [color];
  16.     while (l != NIL) {
  17.         start = l->i;
  18.         l = l->n;
  19.         if (occupant [start] != PAWN)
  20.             continue;
  21.         moves = piecemoves (start, FALSE);
  22.         while (moves != NIL) {
  23.             end = moves->i;
  24.             moves = moves->n;
  25.             if (start % 10 == end % 10)
  26.                 continue;
  27.             if (moveintocheck (start, end))
  28.                 continue;
  29.             tries++;
  30.         }
  31.     }
  32.     return tries;
  33. }
  34.  
  35.  
  36. findvictim (from, to)
  37.     int from, to;
  38. {
  39.     if (occupant [from] == PAWN) {
  40.         if (from % 10 == to % 10)
  41.             return FALSE;
  42.         if (whose [to] == 1 - whose [from])
  43.             return to;
  44.         else
  45.             return (to - pawndir [whose [from]]);  /* en passent */
  46.     } else {
  47.         if (whose [to] == 1 - whose[from])
  48.             return to;
  49.         else
  50.             return FALSE;
  51.     }
  52. }
  53.